package cn.ydxiaoshuai.controller;

import cn.ydxiaoshuai.common.WXConts;
import cn.ydxiaoshuai.po.JSAPIPageBean;
import cn.ydxiaoshuai.util.WXUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * @Description 微信JSAPIController
 * @author 小帅丶
 * @className WXController
 * @Date 2019/12/2-11:22
 **/
@Controller
@RequestMapping(value = "/jsapi")
public class WXJSAPIController {
    @Autowired
    private WXUtil wxUtil;
    /**
     * @Description JSAPI 接入
     * @Author 小帅丶
     * @Date  2019/12/2 14:43
     * @Param [request]
     * @return cn.ydxiaoshuai.po.JSAPIPageBean
     **/
    @RequestMapping("/ticket")
    @ResponseBody
    public JSAPIPageBean ticket(HttpServletRequest request){
        //url 为用户访问的URL 而不是接口发送过来的地址  也是注意修改
        String url = "http://zxshuai.imwork.net/wx/";
        JSAPIPageBean bean = wxUtil.getBean(WXConts.APPID, WXConts.APPSECRET, url);
        return bean;
    }
}
